<template>
  <!-- 查看日常验收记录 -->
  <base-breadcrumb :title="$route.meta.title">
    <a-spin :spinning="loading">
      <!-- 基础信息 -->
      <BaseInfo
        :form="form"
        :isValidate="true"
        disabled
        :replaceFieds="{
          branchCompany: {
            id: 'branchComId',
            name: 'branchComName'
          },
          project: {
            id: 'projectId',
            name: 'projectName'
          }
        }"
      />
      <!-- 质量日常验收信息 -->
      <a-card :bordered="false" style="margin-bottom: 50px">
        <title-name title="质量日常验收信息"></title-name>
        <!-- 表单信息 -->
        <custom-form isValidate :formList="formList" :form="form" editModel="V"> </custom-form>
        <title-name title="技术复核信息"></title-name>
        <a-table
          :pagination="false"
          size="default"
          :rowKey="(record, index) => record ? (record.id + index) : index"
          bordered
          :columns="columns"
          :data-source="form.reviews"
        >
        <template
          slot="fileArrays"
          slot-scope="text, record"
        >
          <BFilePreview
            :disabled="true"
            :list.sync="record.fileArrays"
          />
        </template>
        <template
          slot="action"
          slot-scope="text, record, index"
        >
          <a class="base-btn" @click="lookDetail(record)">查看</a>
        </template>
        </a-table>
      </a-card>
    </a-spin>
    <!-- 页脚操作栏 -->
    <div
      class="btn_box page-btn-right-top"
    >
      <a-button type="primary" @click="$multiTab.close()">关闭</a-button>
    </div>
  </base-breadcrumb>
</template>

<script>
import { acceptanceDailyRecord } from '@/api/quality/quality' // api
import BaseEditPage from '@/views/baseEditPage' // 编辑详情页基础配置
import BaseInfo from '@/components/businessComponents/BaseInfo' // 打印按钮
import BFilePreview from '@/components/BComponents/BFilePreview'
const columns = [
    {
      title: '复核项内容',
      dataIndex: 'content',
    },
    {
      title: '复核人',
      dataIndex: 'employeeName',
    },
    {
      title: '复核项完成时间',
      dataIndex: 'reviewDate',
    },
    {
      title: '复核项图片',
      dataIndex: 'fileArrays',
      scopedSlots: { customRender: 'fileArrays' }
    },
    {
      title: '复核项结果',
      dataIndex: 'resultName',
    },
    {
      title: '操作',
      dataIndex: 'action',
      scopedSlots: { customRender: 'action' },
    },
  ]
export default {
  name: 'a' + Date.now(),
  extends: new BaseEditPage(),
  components: {
    BaseInfo,
    BFilePreview
  },
  data() {
    return {
      loading: false,
      id: '',
      columns,
      editModel: '0',
      // 加载数据方法 必须为 Promise 对象
      form: {} // 表单
    }
  },
  created() {
    this.loading = true
    acceptanceDailyRecord
      .getDetail({
        id: this.id
      })
      .then((res) => {
        this.loading = false
        if (res.data) {
          res.data.checkAcceptanceTypeName = '日常验收'
          res.data.workUtilsName = res.data.workUtilsName?.join('，')
          res.data.respArea = res.data.respArea?.name
          res.data.acceptanceResult = res.data.acceptanceResult?.name
          this.form = res.data
        }
      })
      .catch(() => {
        this.loading = false
      })
  },
  computed: {
    formList() {
      return [
        {
          keyName: 'workUtilsName',
          label: '作业单位'
        },
        {
          keyName: 'checkAcceptanceTypeName',
          label: '验收类型'
        },
        {
          keyName: 'parentTypeName',
          label: '分部分项'
        },
        {
          keyName: 'respArea',
          label: '验收区域'
        },
        {
          keyName: 'part',
          label: '验收部位'
        },
        {
          keyName: 'acceptanceDate',
          label: '计划验收时间'
        },
        {
          keyName: 'content',
          label: '验收内容',
          span: 24
        },
        {
          keyName: 'selfTestDetails',
          label: '自检详情',
          span: 24
        },
        {
          keyName: 'acceptorName',
          label: '验收人'
        },
        {
          keyName: 'modifiedTime',
          label: '实际验收时间'
        },
        {
          keyName: 'fileArrays',
          type: 'uploadFile',
          attrs: {
            disabled: true,
            uploadType: 'image'
          },
          label: '图片',
          span: 24
        },
        // {
        //   keyName: 'reviews',
        //   label: '复核内容',
        //   span: 24
        // },
        // {
        //   keyName: 'acceptorName',
        //   label: '作业单位'
        // },
        // {
        //   keyName: 'acceptanceResult',
        //   label: '验收类型'
        // },
        {
          keyName: 'acceptanceResult',
          label: '验收结果'
        }
      ]
    } // 表单列表
  },
  methods: {
    lookDetail(record){
      this.$router.push({
        name: 'newRecordInfo',
        query: {
          id: record?.id,
          qualityInspectionRecord: false
        }
      })
    },
  },
}
</script>
<style scoped>
.text_name {
  margin-top: -3px;
}
</style>
